package com.culturalCenter.dataCenter.globalconfig;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 方治森
 */
@Configuration
public class RedissonConfig {

    @Value("${redisson.address}")
    private String address;
    @Value("${redisson.password}")
    private String password;
    @Value("${redisson.dataBase}")
    private int dataBase;


    /**
     * 单机模式
     */
    @Bean
    public RedissonClient getRedisson() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress(address)
                .setPassword(password)
                .setDatabase(dataBase)
                .setTimeout(10000);
        return Redisson.create(config);
    }

}
